﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<UserListItemViewModel>>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Users</h2>
    <table>
        <thead>
            <tr>
                <th>
                    User name
                </th>
                <th>
                    Created
                </th>
                <th>
                    Email
                </th>
                <th>
                    Approved
                </th>
                <th>
                    Locked out
                </th>
                <th>
                    Last activity
                </th>
                <th>
                    Roles
                </th>
            </tr>
        </thead>
        <tbody>
            <% foreach (var user in Model)
               { %>
            <tr>
                <td>
                    <%= Html.ActionLink(
                            user.UserName, 
                            "Details", 
                            new { userName = user.UserName }) %>
                </td>
                <td>
                    <%= user.CreationDate %>
                </td>
                <td>
                    <%= user.Email %>
                </td>
                <td>
                    <%= user.IsApproved %>
                </td>
                <td>
                    <%= user.IsLockedOut %>
                </td>
                <td>
                    <%= user.LastActivityDate %>
                </td>
                <td>
                    <%= user.Roles %>
                </td>
            </tr>
            <% } %>
        </tbody>
    </table>
    <div class="createItem">
        <h3>
            Create new user</h3>
        <% using (Html.BeginForm())
           { %>
        <table>
            <tr>
                <th>
                    User name
                </th>
                <td>
                    <%= Html.TextBox("userName") %>
                </td>
            </tr>
            <tr>
                <th>
                    Password
                </th>
                <td>
                    <%= Html.Password("password")%>
                </td>
            </tr>
            <tr>
                <th>
                    Email
                </th>
                <td>
                    <%= Html.TextBox("email") %>
                </td>
            </tr>
        </table>
        <input type="submit" value="Create user" />
        <%} %>
    </div>
</asp:Content>
